<!doctype html>
<html lang="en">
	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Document</title>
	</head>
	<body>
		1212
	</body>
	<script>
		const getTime = () => {
			// FID
			new PerformanceObserver((entryList) => {
				for (const entry of entryList.getEntries()) {
					const delay = entry.processingStart - entry.startTime
					console.log('FID candidate:', delay, entry)
				}
			})
			// LCP
		}
		// getTime()
		const LCP = () => {
			new PerformanceObserver((entryList) => {
				console.log('%c [  ]-26', 'font-size:13px; background:pink; color:#bf2c9f;', entryList)
				for (const entry of entryList.getEntries()) {
					console.log('LCP candidate:', entry.startTime, entry)
				}
			}).observe({ type: 'largest-contentful-paint', buffered: true })
		}
		// getTime()
		// LCP()
		// console.log('%c [  ]-31', 'font-size:13px; background:pink; color:#bf2c9f;', LCP())
		if (window.PerformanceObserver) {
			LCP()
		} else {
			getTime()
		}
		let xhr = window.XMLHttpRequest
		let oldOpen = xhr.prototype.open
		xhr.prototype.open = function (method, url, async, username, password) {
			this.info = {
				method,
				url,
				async,
				username,
				password
			}
			return oldOpen.apply(this, arguments)
		}
		let oldSend = xhr.prototype.send
		xhr.send()
		xhr.prototype.send = function (value) {
			// 请求体长度/ 相应chang du
			return oldSend.apply(this, arguments)
		}

		/*
    fetch
    xhr
    let old =  window.XMLHttpRequest.prototype.open
有技术难度，推动公

    */
	</script>
</html>
